<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改产品二级类型</title>
<link href="${pageContext.request.contextPath }/css/styles.css" rel="stylesheet" type="text/css" />
 <link href="${pageContext.request.contextPath }/css/facebox.css" rel="stylesheet" type="text/css" />
 <link href="${pageContext.request.contextPath }/css/common.css" rel="stylesheet" type="text/css" />
 <script src="${pageContext.request.contextPath }/js/jquery-1.7.2.js" type="text/javascript"></script>
 <script type="text/javascript">
 window.onload = function () { 
	    new uploadPreview({ UpBtn: "upload", DivShow: "imgdiv", ImgShow: "imgShow" });
	}
	function getFullPath(obj) {
		//得到图片的完整路径
		if (obj) {
			//ie
			if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
				obj.select();
				return document.selection.createRange().text;
				}
			//firefox
			else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
				if (obj.files) {
					return obj.files.item(0).getAsDataURL();
					}
				return obj.value;
				}
			return obj.value;
			}
		}
	$(document).ready(function() {

		$("#upload").change(function(){
			var strSrc = $("#upload").val();
			
			/* img = new Image();
			img.src = getFullPath(strSrc); */
			//验证上传文件格式是否正确
			var pos = strSrc.lastIndexOf(".");
			var lastname = strSrc.substring(pos, strSrc.length);
			if (lastname != ".jpg" && lastname != ".png" && lastname != ".gif") {
				alert("您上传的文件类型为" + lastname + "，图片必须为 jpg或png或gif类型");
			}
		});
$("#sub").click(function(){
			
	if($("#upload").val() != ""){
		
		var strSrc = $("#upload").val();
		/* img = new Image();
		img.src = getFullPath(strSrc); */
		//验证上传文件格式是否正确
		var pos = strSrc.lastIndexOf(".");
		var lastname = strSrc.substring(pos, strSrc.length);
		
		if (lastname != ".jpg" && lastname != ".png" && lastname != ".gif") {
			alert("您上传的文件类型为" + lastname + "，图片必须为 jpg或png或gif类型");
			return false;
		}  
	}else{
		alert("图片必须选。");
		return false;
	}
	if($("#Second_Type").val() == ""){
		alert("产品的二级菜单名称必填。");
		return false;
	}
	});
	$("#Second_TypeError").hide();
	$("#Second_Type").blur(function() {
		if ($("#Second_Type").val() == "") {
			$("#Second_TypeError").show();
		} else {

			$("#Second_TypeError").hide();
		}
	});
});
</script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
    <!-- MASTER STYLESHEET-->
    <link href="${pageContext.request.contextPath }/css/styles.css" rel="stylesheet" type="text/css" />
    
    <!-- LOAD TIPSY TOOLTIPS-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.tipsy.js"></script>
   
    <!-- LOAD CUSTOM JQUERY SCRIPTS-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/scripts.js"></script>	
    
	 <!-- LOAD FACEBOX -->
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/facebox.js"></script>
    <link href="${pageContext.request.contextPath }/css/facebox.css" rel="stylesheet" type="text/css" />
    

    <!-- LOAD FLOT GRAPHS -->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.flot.pack.js"></script>
    <!--[if IE]>
     <script language="javascript" type="text/javascript" src="js/excanvas.pack.js"></script>
    <![endif]-->
    
    
    <!--[if IE 6]>
    <script src="js/pngfix.js"></script>
    <script>
        DD_belatedPNG.fix('.png_bg');
    </script>        
    <![endif]-->

	
    <!-- LOAD GRAPH JAVASCRIPT FILE-->
	<script src="${pageContext.request.contextPath }/js/graphs.js" type="text/javascript"></script>
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script src="${pageContext.request.contextPath }/js/uploadPreview.js" type="text/javascript"></script>
<style type="text/css">
#preview{width:260px;height:190px;border:1px solid #000;overflow:hidden;}
#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
body { overflow-x: hidden; overflow-y: auto; } 
</style> 
</head>
<body>
	<div class="result-wrap" style="margin-left: 10%;">
            <form action="${pageContext.request.contextPath }/product/updateSecondType.action" method="post" enctype="multipart/form-data">
                <div class="config-items">
                    <div class="config-title">
                        <h1 style="font-size: 26px;font-family: Tahoma,Geneva,sans-serif;color: #666;">修改产品二级类型</h1>
                    </div>
                    <div class="result-content">
                        <table width="100%" class="insert-tab">
                        	<s:iterator value="#request.list">
                        	 <tr>
                                <th width="15%">请选择产品一级类型：</th>
                                <td><input type="text" id="firstType" name="firstType" value='<s:property value="firstType.Type_Name"/>' readonly="readonly" size="85" name="keywords" class="common-text">
                                <font style="color: red;">产品的一级菜单不能更改</font>
                                </td>
                            </tr>
                            <tr>
                                <th width="15%">产品二级类型：</th>
                                <td><input type="text" id="Type_Name" name="Type_Name" value='<s:property value="Type_Name"/>' size="85" name="keywords" class="common-text">
                                <font id="Type_NameError" style="color: red;">不能为空。</font></td>
                            </tr>
                        	</s:iterator>
                            <tr>
                              	<th></th>
                              	<th align="left"><div id="imgdiv" align="left"><img id="imgShow" src='<s:property value="pritrue"/>' width="100" height="100" /></div></th>
                        </tr>
                         <tr>
                            <th><i class="require-red">*</i>产品上传图片：</th>
                            <td><input style="width: 64%" type="file" id="upload" size="85" name="upload" class="common-text">
                            <span style="color: red;font-size: 12px;">请选择jpg或png或gif格式的图片</span></td>
                        </tr>
                                <tr>
                                    <th></th>
                                    <td>
                                        <input type="submit" id="sub" value="提交" class="btn btn-primary btn6 mr10">
                                        <input type="button" value="返回" onclick="history.go(-1)" class="btn btn6">
                                    </td>
                                </tr>
                            </table>
                    </div>
				</div>
			</form>
		</div>
</body>
</html>